package com.lipengcheng.order.web;

import com.lipengcheng.feign.clients.ItemFeignClient;
import com.lipengcheng.feign.clients.UserFeignClient;
import com.lipengcheng.feign.common.dto.Address;
import com.lipengcheng.feign.common.dto.Item;
import com.lipengcheng.order.pojo.Order;
import com.lipengcheng.order.pojo.OrderDetail;
import com.lipengcheng.order.pojo.OrderLogistics;
import com.lipengcheng.order.pojo.PaymentDetail;
import com.lipengcheng.order.service.IOrderService;
import com.lipengcheng.order.service.OrderDetailService;
import com.lipengcheng.order.service.OrderLogisticsService;
import com.lipengcheng.order.utils.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;
   @Autowired
   private ItemFeignClient client;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      Long userId = UserHolder.getUserId();
      System.err.println(userId);
      return orderService.getById(orderId);
   }

   /**
    * 提交订单
    * @param paymentDetail
    * @return
    */
   @PostMapping
   public Long submitOrder(@RequestBody PaymentDetail paymentDetail){


      return orderService.submitOrder(paymentDetail);
   }
}
